import React, { useState,useEffect } from 'react'
import Header from '../../components/Header/Header'
import ListMenu from './ListMenu/ListMenu.jsx'
import ShopList from './ShopList/ShopList.jsx'
import "./Cate.less"
// import { connect } from "react-redux";
// import { bindActionCreators } from "redux";
// import {actions,getListmenu,getShoplist,getN} from '../../store/modules/cate'
import { reqgetcate, reqgetgoods } from '../../http/api'


const Cate = ()=>{
  const [listmenu,setListmenu] = useState([])
  const [shoplist,setShoplist] = useState([])
  const [n, setn] = useState(0);

useEffect(()=>{
  //请求
  reqgetcate().then((res)=>{
    setListmenu(res.data.list)
  });
  //请求商品列表
  reqgetgoods().then((res)=>{
    setShoplist(res.data.list)
  })


},[])


    return (
      <div className='cate'>
        <Header back title="分类"></Header>
        <div className='cate_list_menu'>
          {/* 左侧的菜单 */}
          <ListMenu
            listmenu={listmenu}
            n={n}
            onChangeN={(v)=>setn(v)}
          ></ListMenu>
        </div>
        <div className='cate_shop_list'>
          {/* 右侧的商品展示区 */}
          <ShopList shoplist={shoplist}></ShopList>
        </div>
      </div>
    )
}
  

 




export default Cate;
